package test00.test06;

import test07.t04.Studunt;

import java.util.Optional;

/**
 * @Author lzp
 * @Date 2024-04-12
 */
public class Test01 {
    public static void main(String[] args) {

        Studunt stu1 = new Studunt("Zs",18);
        Studunt stu2 = new Studunt(null,18);

        Optional<String> optional1 = Optional.ofNullable(stu1.getName());
        String a = optional1.orElseGet(() -> {
            return "匿名";
        }).toLowerCase();
        System.out.println(a);

        Optional<String> optional2 = Optional.ofNullable(stu2.getName());
        String b = optional2.orElseGet(() -> {
            return "匿名";
        }).toLowerCase();
        System.out.println(b);



    }
}
